<!DOCTYPE html>
<html lang="en" xmlns="http://www.w3.org/1999/xhtml"
      xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity5">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script src="/jquery/jquery-3.6.0.min.js"></script>
    <script src="/layui-v2.6.8/layui/layui.js"></script>
    <link rel="stylesheet" href="/layui-v2.6.8/layui/css/layui.css">
    <script>
        $(function (){
            let path;

            $("#btn").click(function (){
                $.get({
                    url: "/getPath",
                    data: {
                        userId: $("#userId").val(),
                        goodId: $("#goodId").val()
                    },
                    success: function (result){
                        if (result.code === "000000" ){
                            path=result.data;

                            $.get({
                                url: "/"+path+"/hello",
                                data: {
                                    userId: $("#userId").val(),
                                    goodId: $("#goodId").val(),
                                    name: "瓜田李下",
                                    age: 20
                                },
                                success: function (result){
                                    if (result.code==="000000"){
                                        layer.msg(result.data);
                                    }else {
                                        layer.msg(result.message)
                                    }
                                }
                            })
                        }else {
                            layer.msg(result.message);
                        }
                    }
                })
            })
        })
    </script>
</head>
<body>
    <div th:align="center">
        <div class="layui-form-item">
            <label class="layui-form-label" style="color: coral;font-weight: bolder">userId</label>
            <div class="layui-input-inline">
                <input type="text" id="userId" required  lay-verify="required" placeholder="请输入userId" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <label class="layui-form-label" style="color: coral;font-weight: bolder">goodId</label>
            <div class="layui-input-inline">
                <input type="text" id="goodId" required lay-verify="required" placeholder="请输入goodId" autocomplete="off" class="layui-input">
            </div>
        </div>
        <div class="layui-form-item">
            <div class="layui-input-inline">
                <button id="btn" class="layui-btn">提交</button>
            </div>
        </div>
    </div>
</body>
</html>